--init.lua
--uart.setup(0, 9600, 8, uart.PARITY_NONE, uart.STOPBITS_1, 1)
print("\r\nthis is the init.lua - by liuke\r\n")

for i=0,6 do
    tmr.stop(i)
end

System_led = 4
gpio.mode(System_led, gpio.OUTPUT)
for i=1, 3, 1 do
    gpio.write(System_led, gpio.LOW)
    tmr.delay(100000)
    gpio.write(System_led, gpio.HIGH)
    tmr.delay(200000)
end

dofile("connWifi.lua")

-- check wifi status on time
tmr.alarm(1, 60000, 1, function() 
    dofile("connWifi.lua") 
end)    

-- send socket message on time
tmr.alarm(2, 30000, 1, function()
    if wifi.sta.status()==5 then
        dofile("tcpClient.lua")
    else
        print("error : wifi status")
        print(wifi.sta.status())
    end
end)
